import 'dart:convert';

import 'package:example_example/global/Global.dart';
import 'package:example_example/global/GlobalUrl.dart';
import 'package:example_example/util/HttpUtil.dart';
import 'package:example_example/util/LogUtil.dart';
import 'package:example_example/util/Storage.dart';

class HttpMethod {

  static initDictionaryData(mContext) async {

    LogUtil.v("字典表工具 initDictionaryData。。。");
    String dictionaryUrl = GlobalUrl.DICTIONARYALLURL;
    var map = {
//      "size": "10",
    };
    String access_token = await Storage.getToken();
    LogUtil.init(title: "来自LogUtil", isDebug: false, limitLength: 800);
    var mapHeaders = {
      Global.AUTHORIZATION: access_token,
      Global.CONTENT_TYPE: Global.APPLICATION_JSON
    };
    LogUtil.v("字典表工具 initDictionaryData222");
    HttpUtil.get(dictionaryUrl,
        context: mContext, data: null, headers: mapHeaders, success: (data) {
      LogUtil.v("字典表工具类的接口数据：$data");
      var success = data["success"];
      var body = data["data"];
      if (success != null && success == true) {
        String strBody = json.encode(body); // Map 转换成 Json 字符串
        print("strBody: $strBody");
        Storage.setString(Global.DICTIONARY, strBody);
      }
    }, error: (errorMsg) {
      print("字典表error...: $errorMsg");
    });
  }
}
